package br.com.beautycenter.view;

import br.com.beautycenter.DAO.PersisteFuncionario;
import java.awt.BorderLayout;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import org.joda.time.DateTime;

public class Principal extends javax.swing.JFrame {

    
    PersisteFuncionario persisteFuncionario = new PersisteFuncionario();
    
    /**
     * Configurações iniciais do sistema
     */
    public void inicializarTela(){
        
       
        this.setExtendedState(getExtendedState() | MAXIMIZED_BOTH);//maximiza a tela
        this.pack();
        this.getContentPane().setBackground(Color.WHITE); //muda o fundo para branco

        //inserindo a logo centralizada
        jPanelLogo.setLayout(new BorderLayout());
        ImageIcon icon = new ImageIcon(getClass().getResource("/br/com/beautycenter/img/Logo.jpg"));
        JLabel logo = new JLabel(icon);
        jPanelLogo.add(logo, BorderLayout.CENTER);
    }
    
    
    public Principal() {
        initComponents();
        inicializarTela();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPainelBotoes = new javax.swing.JPanel();
        btnFuncionario = new javax.swing.JButton();
        btnCliente = new javax.swing.JButton();
        btnAgenda = new javax.swing.JButton();
        btnFinanceiro = new javax.swing.JButton();
        btnBackup = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();
        btnVenda = new javax.swing.JButton();
        btnPesquisarClienteDigital = new javax.swing.JButton();
        jPanelLogo = new javax.swing.JPanel();
        jMenuBarPrincipal = new javax.swing.JMenuBar();
        jMenuSistema = new javax.swing.JMenu();
        jMenuItemAgenda = new javax.swing.JMenuItem();
        jMenuItemSuporte = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenuItemVersao = new javax.swing.JMenuItem();
        jMenuSair = new javax.swing.JMenuItem();
        jMenuCadastro = new javax.swing.JMenu();
        jMenuItemCadastroFuncionario = new javax.swing.JMenuItem();
        jMenuItemCadastroCliente = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItemCadastroCargo = new javax.swing.JMenuItem();
        jMenuItemCadastroTratamento = new javax.swing.JMenuItem();
        jMenuItemCadastroTipoDespesa = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItemCadastroProduto = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JPopupMenu.Separator();
        jMenuItemCadastroFeriado = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuControleAtendimento = new javax.swing.JMenuItem();
        jMAtendimentosPorPeriodo = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMClientePelaDigital = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuDespesa = new javax.swing.JMenuItem();
        jMenuSangria = new javax.swing.JMenuItem();
        jMenuSuprimento = new javax.swing.JMenuItem();
        jMenuItemRecebimentoExtra = new javax.swing.JMenuItem();
        jMenuFechamentoCaixa = new javax.swing.JMenuItem();
        jSeparator6 = new javax.swing.JPopupMenu.Separator();
        jMConfirmarRecebimento = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("ERP BEAUTY CENTER - SEJA BEM VINDO");
        setBackground(new java.awt.Color(255, 255, 255));
        setResizable(false);

        jPainelBotoes.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647));
        jPainelBotoes.setPreferredSize(new java.awt.Dimension(800, 45));

        btnFuncionario.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        btnFuncionario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Funcionario.png"))); // NOI18N
        btnFuncionario.setToolTipText("Funcionario");
        btnFuncionario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFuncionarioActionPerformed(evt);
            }
        });

        btnCliente.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        btnCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Paciente.png"))); // NOI18N
        btnCliente.setToolTipText("Cliente");
        btnCliente.setPreferredSize(new java.awt.Dimension(60, 40));
        btnCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClienteActionPerformed(evt);
            }
        });

        btnAgenda.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        btnAgenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Agenda.png"))); // NOI18N
        btnAgenda.setToolTipText("Agenda");
        btnAgenda.setPreferredSize(new java.awt.Dimension(60, 40));
        btnAgenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgendaActionPerformed(evt);
            }
        });

        btnFinanceiro.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        btnFinanceiro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Financeiro.png"))); // NOI18N
        btnFinanceiro.setToolTipText("Financeiro");
        btnFinanceiro.setPreferredSize(new java.awt.Dimension(60, 40));
        btnFinanceiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinanceiroActionPerformed(evt);
            }
        });

        btnBackup.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        btnBackup.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Backup.png"))); // NOI18N
        btnBackup.setToolTipText("Backup");
        btnBackup.setPreferredSize(new java.awt.Dimension(60, 40));
        btnBackup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBackupActionPerformed(evt);
            }
        });

        btnSair.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Sair.png"))); // NOI18N
        btnSair.setToolTipText("Sair");
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });

        btnVenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/Vendas.png"))); // NOI18N
        btnVenda.setToolTipText("Vendas");
        btnVenda.setPreferredSize(new java.awt.Dimension(60, 40));
        btnVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVendaActionPerformed(evt);
            }
        });

        btnPesquisarClienteDigital.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/beautycenter/img/digital.png"))); // NOI18N
        btnPesquisarClienteDigital.setToolTipText("Pesquisar Cliente Pela Digital");
        btnPesquisarClienteDigital.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarClienteDigitalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPainelBotoesLayout = new javax.swing.GroupLayout(jPainelBotoes);
        jPainelBotoes.setLayout(jPainelBotoesLayout);
        jPainelBotoesLayout.setHorizontalGroup(
            jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPainelBotoesLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(btnFuncionario)
                .addGap(6, 6, 6)
                .addComponent(btnCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPesquisarClienteDigital)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnVenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(btnAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(btnFinanceiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(btnBackup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPainelBotoesLayout.setVerticalGroup(
            jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPainelBotoesLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addGroup(jPainelBotoesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPesquisarClienteDigital)
                    .addComponent(btnFuncionario)
                    .addComponent(btnCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnFinanceiro, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnBackup, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSair))
                .addContainerGap())
        );

        jPanelLogo.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout jPanelLogoLayout = new javax.swing.GroupLayout(jPanelLogo);
        jPanelLogo.setLayout(jPanelLogoLayout);
        jPanelLogoLayout.setHorizontalGroup(
            jPanelLogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 800, Short.MAX_VALUE)
        );
        jPanelLogoLayout.setVerticalGroup(
            jPanelLogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 529, Short.MAX_VALUE)
        );

        jMenuBarPrincipal.setPreferredSize(new java.awt.Dimension(293, 20));

        jMenuSistema.setText("Sistema");

        jMenuItemAgenda.setText("Agenda");
        jMenuItemAgenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAgendaActionPerformed(evt);
            }
        });
        jMenuSistema.add(jMenuItemAgenda);

        jMenuItemSuporte.setText("Suporte - Contatos");
        jMenuSistema.add(jMenuItemSuporte);
        jMenuSistema.add(jSeparator3);

        jMenuItemVersao.setText("Versão");
        jMenuSistema.add(jMenuItemVersao);

        jMenuSair.setText("Sair");
        jMenuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuSairActionPerformed(evt);
            }
        });
        jMenuSistema.add(jMenuSair);

        jMenuBarPrincipal.add(jMenuSistema);

        jMenuCadastro.setText("Cadastros");

        jMenuItemCadastroFuncionario.setText("Funcionario");
        jMenuItemCadastroFuncionario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroFuncionarioActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroFuncionario);

        jMenuItemCadastroCliente.setText("Cliente");
        jMenuItemCadastroCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroClienteActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroCliente);
        jMenuCadastro.add(jSeparator1);

        jMenuItemCadastroCargo.setText("Cargos");
        jMenuItemCadastroCargo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroCargoActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroCargo);

        jMenuItemCadastroTratamento.setText("Tratamentos");
        jMenuItemCadastroTratamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroTratamentoActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroTratamento);

        jMenuItemCadastroTipoDespesa.setText("Tipos de Despesas");
        jMenuItemCadastroTipoDespesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroTipoDespesaActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroTipoDespesa);
        jMenuCadastro.add(jSeparator2);

        jMenuItemCadastroProduto.setText("Produtos");
        jMenuItemCadastroProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroProdutoActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroProduto);
        jMenuCadastro.add(jSeparator5);

        jMenuItemCadastroFeriado.setText("Feriados");
        jMenuItemCadastroFeriado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCadastroFeriadoActionPerformed(evt);
            }
        });
        jMenuCadastro.add(jMenuItemCadastroFeriado);

        jMenuBarPrincipal.add(jMenuCadastro);

        jMenu1.setText("Relatorios");

        jMenuControleAtendimento.setText("Controle de Atendimento");
        jMenuControleAtendimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuControleAtendimentoActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuControleAtendimento);

        jMAtendimentosPorPeriodo.setText("Atendimentos por Período");
        jMAtendimentosPorPeriodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMAtendimentosPorPeriodoActionPerformed(evt);
            }
        });
        jMenu1.add(jMAtendimentosPorPeriodo);

        jMenuBarPrincipal.add(jMenu1);

        jMenu2.setText("Pesquisar");

        jMClientePelaDigital.setText("Cliente Pela Digital");
        jMClientePelaDigital.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMClientePelaDigitalActionPerformed(evt);
            }
        });
        jMenu2.add(jMClientePelaDigital);

        jMenuBarPrincipal.add(jMenu2);

        jMenu3.setText("Financeiro");

        jMenuDespesa.setText("Despesas");
        jMenuDespesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDespesaActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuDespesa);

        jMenuSangria.setText("Sangria");
        jMenuSangria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuSangriaActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuSangria);

        jMenuSuprimento.setText("Suprimento");
        jMenuSuprimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuSuprimentoActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuSuprimento);

        jMenuItemRecebimentoExtra.setText("Recebimento Extra");
        jMenuItemRecebimentoExtra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemRecebimentoExtraActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItemRecebimentoExtra);

        jMenuFechamentoCaixa.setText("Fechamento Diario");
        jMenuFechamentoCaixa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuFechamentoCaixaActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuFechamentoCaixa);
        jMenu3.add(jSeparator6);

        jMConfirmarRecebimento.setText("Confirmar Recebimento");
        jMConfirmarRecebimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMConfirmarRecebimentoActionPerformed(evt);
            }
        });
        jMenu3.add(jMConfirmarRecebimento);

        jMenuBarPrincipal.add(jMenu3);

        setJMenuBar(jMenuBarPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPainelBotoes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanelLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPainelBotoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClienteActionPerformed
        cadastroCliente();
    }//GEN-LAST:event_btnClienteActionPerformed

    private void jMenuItemCadastroClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroClienteActionPerformed
        cadastroCliente();
    }//GEN-LAST:event_jMenuItemCadastroClienteActionPerformed

    private void btnFuncionarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFuncionarioActionPerformed
        cadastroFuncionario();
    }//GEN-LAST:event_btnFuncionarioActionPerformed

    private void jMenuItemRecebimentoExtraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemRecebimentoExtraActionPerformed
        CadastroRecebimentoExtra recebimento = new CadastroRecebimentoExtra();
        recebimento.setLocationRelativeTo(null);
        recebimento.setVisible(true);
    }//GEN-LAST:event_jMenuItemRecebimentoExtraActionPerformed

    private void jMenuFechamentoCaixaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuFechamentoCaixaActionPerformed
        fechamentoCaixa();
    }//GEN-LAST:event_jMenuFechamentoCaixaActionPerformed

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        fecharSistema();
    }//GEN-LAST:event_btnSairActionPerformed

    private void jMenuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuSairActionPerformed
        fecharSistema();
    }//GEN-LAST:event_jMenuSairActionPerformed

    private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackupActionPerformed
        realizarBackup();
    }//GEN-LAST:event_btnBackupActionPerformed

    private void jMenuItemCadastroTratamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroTratamentoActionPerformed
        CadastroTratamento cadastroTratamento= new CadastroTratamento();
        cadastroTratamento.setLocationRelativeTo(null);
        cadastroTratamento.setVisible(true);
    }//GEN-LAST:event_jMenuItemCadastroTratamentoActionPerformed

    private void jMenuSuprimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuSuprimentoActionPerformed
        CadastroSuprimento suprimento = new CadastroSuprimento();
        suprimento.setLocationRelativeTo(null);
        suprimento.setVisible(true);
    }//GEN-LAST:event_jMenuSuprimentoActionPerformed

    private void jMenuSangriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuSangriaActionPerformed
        CadastroSangria sangria = new CadastroSangria();
        sangria.setLocationRelativeTo(null);
        sangria.setVisible(true);
    }//GEN-LAST:event_jMenuSangriaActionPerformed

    private void jMenuItemCadastroFuncionarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroFuncionarioActionPerformed
        cadastroFuncionario();
    }//GEN-LAST:event_jMenuItemCadastroFuncionarioActionPerformed

    private void btnAgendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgendaActionPerformed
        agenda();
    }//GEN-LAST:event_btnAgendaActionPerformed

    private void jMenuItemAgendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAgendaActionPerformed
        agenda();
    }//GEN-LAST:event_jMenuItemAgendaActionPerformed

    private void jMenuItemCadastroProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroProdutoActionPerformed
        CadastroProdutos cadastroProdutos = new CadastroProdutos();
        cadastroProdutos.setLocationRelativeTo(null);
        cadastroProdutos.setVisible(true);
    }//GEN-LAST:event_jMenuItemCadastroProdutoActionPerformed

    private void jMenuControleAtendimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuControleAtendimentoActionPerformed
        ControleAtendimento controleAtendimento = new ControleAtendimento(null, false);
        controleAtendimento.setLocationRelativeTo(null);
        controleAtendimento.setVisible(true);
    }//GEN-LAST:event_jMenuControleAtendimentoActionPerformed

    private void jMenuItemCadastroFeriadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroFeriadoActionPerformed
        CadastroFeriados cadastroFeriado = new CadastroFeriados();
        cadastroFeriado.setLocationRelativeTo(null);
        cadastroFeriado.setVisible(true);
    }//GEN-LAST:event_jMenuItemCadastroFeriadoActionPerformed

    private void jMenuItemCadastroCargoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroCargoActionPerformed
        cadastroCargo();
    }//GEN-LAST:event_jMenuItemCadastroCargoActionPerformed

    private void btnVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVendaActionPerformed
        ModuloVendas vendas = new ModuloVendas(this, rootPaneCheckingEnabled);
        vendas.setLocationRelativeTo(null);
        vendas.setVisible(true);
    }//GEN-LAST:event_btnVendaActionPerformed

    private void btnFinanceiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinanceiroActionPerformed
        fechamentoCaixa();
    }//GEN-LAST:event_btnFinanceiroActionPerformed

    private void jMConfirmarRecebimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMConfirmarRecebimentoActionPerformed
        ConfirmarPagamento confirmarPagamento = new ConfirmarPagamento();
        confirmarPagamento.setLocationRelativeTo(null);
        confirmarPagamento.setVisible(true);
    }//GEN-LAST:event_jMConfirmarRecebimentoActionPerformed

    private void jMAtendimentosPorPeriodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMAtendimentosPorPeriodoActionPerformed
        AtendimentosPorPeriodo atendimento = new AtendimentosPorPeriodo();
        atendimento.setLocationRelativeTo(null);
        atendimento.setVisible(true);
    }//GEN-LAST:event_jMAtendimentosPorPeriodoActionPerformed

    private void jMClientePelaDigitalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMClientePelaDigitalActionPerformed
        PesquisarDigital pesquisarDigital = new PesquisarDigital(this, true);
        pesquisarDigital.setLocationRelativeTo(null);
        pesquisarDigital.setVisible(true);
    }//GEN-LAST:event_jMClientePelaDigitalActionPerformed

    private void btnPesquisarClienteDigitalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarClienteDigitalActionPerformed
        PesquisarDigital pesquisarDigital = new PesquisarDigital(this, true);
        pesquisarDigital.setLocationRelativeTo(null);
        pesquisarDigital.setVisible(true);
    }//GEN-LAST:event_btnPesquisarClienteDigitalActionPerformed

    private void jMenuDespesaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDespesaActionPerformed
        CadastroDespesas despesas = new CadastroDespesas();
        despesas.setLocationRelativeTo(null);
        despesas.setVisible(true);
    }//GEN-LAST:event_jMenuDespesaActionPerformed

    private void jMenuItemCadastroTipoDespesaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCadastroTipoDespesaActionPerformed
        CadastrarTipoDespesa tipoDespesa = new CadastrarTipoDespesa(this, true);
        tipoDespesa.setLocationRelativeTo(null);
        tipoDespesa.setVisible(true);
    }//GEN-LAST:event_jMenuItemCadastroTipoDespesaActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
    
                try{
                    
                    Thread.sleep(4500);
                    
                    }catch(Exception e){
                    
                        
                    }
                new Principal().setVisible(true);

            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgenda;
    private javax.swing.JButton btnBackup;
    private javax.swing.JButton btnCliente;
    private javax.swing.JButton btnFinanceiro;
    private javax.swing.JButton btnFuncionario;
    private javax.swing.JButton btnPesquisarClienteDigital;
    private javax.swing.JButton btnSair;
    private javax.swing.JButton btnVenda;
    private javax.swing.JMenuItem jMAtendimentosPorPeriodo;
    private javax.swing.JMenuItem jMClientePelaDigital;
    private javax.swing.JMenuItem jMConfirmarRecebimento;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBarPrincipal;
    private javax.swing.JMenu jMenuCadastro;
    private javax.swing.JMenuItem jMenuControleAtendimento;
    private javax.swing.JMenuItem jMenuDespesa;
    private javax.swing.JMenuItem jMenuFechamentoCaixa;
    private javax.swing.JMenuItem jMenuItemAgenda;
    private javax.swing.JMenuItem jMenuItemCadastroCargo;
    private javax.swing.JMenuItem jMenuItemCadastroCliente;
    private javax.swing.JMenuItem jMenuItemCadastroFeriado;
    private javax.swing.JMenuItem jMenuItemCadastroFuncionario;
    private javax.swing.JMenuItem jMenuItemCadastroProduto;
    private javax.swing.JMenuItem jMenuItemCadastroTipoDespesa;
    private javax.swing.JMenuItem jMenuItemCadastroTratamento;
    private javax.swing.JMenuItem jMenuItemRecebimentoExtra;
    private javax.swing.JMenuItem jMenuItemSuporte;
    private javax.swing.JMenuItem jMenuItemVersao;
    private javax.swing.JMenuItem jMenuSair;
    private javax.swing.JMenuItem jMenuSangria;
    private javax.swing.JMenu jMenuSistema;
    private javax.swing.JMenuItem jMenuSuprimento;
    private javax.swing.JPanel jPainelBotoes;
    private javax.swing.JPanel jPanelLogo;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator5;
    private javax.swing.JPopupMenu.Separator jSeparator6;
    // End of variables declaration//GEN-END:variables

    private void realizarBackup(){
                
        DateTime cal = new DateTime();  
        
        int dia = cal.getDayOfMonth();  
        int mes = cal.getMonthOfYear();  
        int ano = cal.getYear();  
        
        String senhaBancoDados = "123456";   
        String nomeBancoDados ="erpbeautycenter";
  
        File diretorio = new File("C:/Backup");  
        File arquivo = new File("C:/Backup/bkp_"+nomeBancoDados+"_"+ano+"_"+mes+"_"+dia+".sql");  
        
        Boolean snbkp = true;  
        
        // Cria diretório  
        if(!diretorio.isDirectory()) new File("C:/Backup").mkdir();  
        // Cria Arquivo de Backup  
        try {  
            if (arquivo.isFile()){   
                if(JOptionPane.showConfirmDialog(null,"Ja foi criado backup hoje, deseja substituir ?","Backup ja existe",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)==JOptionPane.YES_OPTION)  
                {   
                    arquivo.delete();  
                    snbkp = true;  
                }  
            else  
                {  
                    snbkp = false;  
                }   
            }  
            
            if(snbkp==true){   
  
                //String comando = "C:\\Program Files (x86)\\MySQL\\MySQL Server 5.0\\bin\\mysqldump";
                String comando = "C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqldump";
                ProcessBuilder pb = new ProcessBuilder(comando, "--user=erpbeautycenter",  
                    "--password="+senhaBancoDados, nomeBancoDados, "--result-file=C:\\Backup\\bkp_" +nomeBancoDados+"_"+ano+  
                      "_"+mes+"_"+dia+".sql");  
                pb.start();  
          
                int res = 0; 
        
      
                if (res == 0)  
          
                    JOptionPane.showMessageDialog(null,"Backup criado com Sucesso !"); 
                
      
                else  {  
          
                        JOptionPane.showMessageDialog(null,"Falha ao criar Backup. \n Verifique as configurações ou entre em contato com o suporte !",  
                        "Erro ao criar backup", JOptionPane.ERROR_MESSAGE);  
                
                }   
            }  
        }  
        catch (IOException ex) {  
      
            ex.printStackTrace();  
            System.out.println(ex);   
            JOptionPane.showMessageDialog(null,"Erro na criação do Backup !");
            
        } catch(Exception erro){  
            
            System.out.println(erro);  
            JOptionPane.showMessageDialog(null,"Erro na criação do Backup !");  
  
        } 
    }
    
    private void fecharSistema() {
        JDialog.setDefaultLookAndFeelDecorated(true);  
        int response = JOptionPane.showConfirmDialog(null, "Deseja realmente sair do sistema?" , "Confirme",  
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);  
            if(response == JOptionPane.NO_OPTION) {  
                //não faz nada pois não precisa... vai dar o dialogo e voltar a tela... 
            } else if (response == JOptionPane.YES_OPTION) {  
                        dispose(); 
                    }
    }
    
    private void agenda(){
        AgendaTratamentos at = new AgendaTratamentos();
        at.setLocationRelativeTo(null);
        at.setVisible(true);        
    }
    
    private void cadastroFuncionario(){
        CadastroFuncionario cadastroFuncionario = new CadastroFuncionario();
        cadastroFuncionario.setLocationRelativeTo(null);
        cadastroFuncionario.setVisible(true);        
    }
    
    private void cadastroCliente(){
        CadastroCliente cadastroPaciente = new CadastroCliente();
        cadastroPaciente.setLocationRelativeTo(null);
        cadastroPaciente.setVisible(true);        
    }
    
    private void cadastroCargo(){
       CadastroCargo cadastroCargo = new CadastroCargo();
       cadastroCargo.setLocationRelativeTo(null);
       cadastroCargo.setVisible(true);        
    }
    
    private void fechamentoCaixa(){
        CadastroFechamentoCaixa fechamento = new CadastroFechamentoCaixa();
        fechamento.setLocationRelativeTo(null);
        fechamento.setVisible(true);
    }
}